﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient ;
using System.Reflection;
using System.Resources;
using System.Windows.Forms;
using Microsoft.Win32;
using System.IO;
using System.Text;

namespace PointOfSale.Global
{
	public class clsGlobal
	{
		public static mainForm g_objfrmMDIMain;

		public static clsDatabase Db = new clsDatabase ();

		public static  string g_UserName = "";
		public static  string g_SQLUserName = "";
		public static  string g_SQLPassword = "";
		public static  string g_ServerIPAddress = "";
		public static  string g_DatabaseName = "";
		public static  bool g_UserPrivilige = false;

		public static  string g_HMS_UserName = "";
		public static  string g_HMS_SQLUserName = "";
		public static  string g_HMS_SQLPassword = "";
		public static  string g_HMS_ServerIPAddress = "";
		public static  string g_HMS_DatabaseName = "";


		public static  string g_DatabaseNameLogin = "";

		public static  string g_CompanyName = "";
		public static  string g_CompanyAddress = "";
		public static  string g_CompanyMSThue = "";
		public static  string g_CompanyTel = "";
		public static  string g_CompanyFax = "";
		public static  string g_CompanyEmail = "";
		public static  string g_CompanyWebsite = "";
		public static SqlConnection g_Conn = new SqlConnection();
		public static SqlConnection g_DataConn = new SqlConnection();
		public static SqlConnection g_HMS_DataConn = new SqlConnection();
		public static ResourceManager sm_oResource = new ResourceManager("AccountingSoftware.Resource1", Assembly.GetExecutingAssembly());
		public static string g_AppPath = Application.ExecutablePath.Replace("bin\\Debug\\"+Application.ProductName + ".exe", "");

		public static int g_UserId = 0;
		public static int g_DepartmentId = 0;
		public static String g_DepartmentName = "";
		public static double g_AmtPaid = 0;
		public static int g_GuestUnkid;
		public static string g_RoomNumber = "";
		public static string g_UserPassword = "";

		public static bool g_isChangeUser = false;
		public static bool g_isExit;

		//Cho viec load len ten khach moi duoc add
		public static bool g_isAddVendorFromPurchase = false;
		public static string g_VendorName = "";
		public clsGlobal()
		{
		}
		public static bool IsNumber (string strSo)
		{
			bool booIsNumber = false;
			try 
			{
				double dblNumber = System.Convert.ToDouble (strSo);
				booIsNumber = true;
			}
			catch (Exception e)
			{
				booIsNumber = false;
			}
			return booIsNumber;

		}
		public static bool isNumber(string strNum)
		{
			int a = 0;
			try
			{
				a = int.Parse(strNum);
				return true;
			}
			catch (FormatException o)
			{
				return false;
			}

		}
		#region Global constants

		#region Common	
		public const string g_INI_FILE_NAME = "ServerConfig.ini";
	/// <summary>
		/// The enumeration contains object types.
		/// </summary>
		public enum ACObjectTypes : int
		{
			Batch = 1,	
			Document = 2,
			Page = 3,
			LoosePage = 4,
			Zone = 5,
		}
		#endregion Common
		
		#endregion Constants
		#region Static methods
				
		/// <summary>
		/// Append a new line to the existing file.
		/// </summary>		
		public static void AppendToFile(string strFilePath, string strNewLine)
		{			
			StreamWriter oStreamWriter;
			try
			{
				if (!File.Exists(strFilePath))
				{
					File.CreateText(strFilePath).Close();
				}
				//oStreamWriter = File.CreateText(strFilePath);
				//oStreamWriter.NewLine = strNewLine;
				oStreamWriter = File.AppendText(strFilePath);
				oStreamWriter.WriteLine(strNewLine);
				oStreamWriter.Close();
			}
			catch(Exception e)
			{
				throw e;
			}
			
		}

		#endregion Static methods
	}
}
